/**
@author		Jong Min, Lee
@date		  02/06/2014
@brief		toolbar layout information

copyright(c) Tae Young Soft. All right reserved. 2014
*/
#include "stdafx.h"
#include "Taurus_Viewer/TBLayoutInfo.h"

DWORD CToolbarLayout::getToolbarPresetArea(MonitorResolutionType enumResType, 
                                           ToolbarPosition enumToolbarPos, 
                                           const CRect& rcParent, 
                                           CRect& rcToolbar)
{
  //vertical toolbar width
  const int nNORMAL_WIDTH = V_TB_TOOLBOX_WIDTH_NORMAL +
                            V_TB_MARGIN_NORMAL * 2;

  const int n3M_WIDTH = V_TB_TOOLBOX_WIDTH_3M +
                        V_TB_MARGIN_3M * 2;

  const int n5M_WIDTH = V_TB_TOOLBOX_WIDTH_5M +
                        V_TB_MARGIN_5M * 2;

  //horizontal toolbar height
  const int nNORMAL_HEIGHT = H_TB_TOOLBOX_HEIGHT_NORMAL +
                             H_TB_MARGIN_3M * 2;

  const int n3M_HEIGHT = H_TB_TOOLBOX_HEIGHT_3M +
                         V_TB_MARGIN_3M * 2;

  const int n5M_HEIGHT = H_TB_TOOLBOX_HEIGHT_5M +
                         H_TB_MARGIN_5M * 2;

  //vertical toolbar width
  int nVToolbarWidth = 0;
  //vertical toolbar height
  int nHToolbarHeight = 0;
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    nVToolbarWidth = nNORMAL_WIDTH;
    nHToolbarHeight = nNORMAL_HEIGHT;
    break;
  case MonitorResolution_3M:
    nVToolbarWidth = n3M_WIDTH;
    nHToolbarHeight = n3M_HEIGHT;
    break;
  case MonitorResolution_5M:
    nVToolbarWidth = n5M_WIDTH;
    nHToolbarHeight = n5M_HEIGHT;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }

  switch(enumToolbarPos)
  {
  case ToolbarPositionLeft:
    {
      rcToolbar = CRect(CPoint(rcParent.left, rcParent.top),
        CSize(nVToolbarWidth, rcParent.Height()));
    }
    break;

  case ToolbarPositionTop:
    {
      rcToolbar = CRect(CPoint(rcParent.left, rcParent.top),
        CSize(rcParent.Width(), nHToolbarHeight));
    }
    break;
  case ToolbarPositionRight:
    {
      rcToolbar = CRect(CPoint(rcParent.right - nVToolbarWidth, rcParent.top),
        CSize(nVToolbarWidth, rcParent.Height()));
    }
    break;
  case ToolbarPositionBottom:
    {
      rcToolbar = CRect(CPoint(rcParent.left, rcParent.bottom - nHToolbarHeight),
        CSize(rcParent.Width(), nHToolbarHeight));
    }
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }
  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getMonitorLayoutPresetArea(MonitorResolutionType enumResType, 
                                                 ToolbarPosition enumToolbarPos, 
                                                 CRect& rcArea)
{
  //check whether toolbar position is vertical or horizontal
  int nVertical = isVertical(enumToolbarPos);
  if(nVertical < 0)
    return ERROR_INVALID_PARAMETER;

  if(nVertical == 1)
    return getMonitorLayoutPresetArea_v(enumResType, rcArea);
  else
    return getMonitorLayoutPresetArea_h(enumResType, rcArea);
}

DWORD CToolbarLayout::getMonitorLayoutPresetArea_v(MonitorResolutionType enumResType, 
                                                   CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = V_TB_MONITOR_LAYOUT_LEFT_NORMAL;
    rcArea.top  = V_TB_MONITOR_LAYOUT_TOP_NORMAL;
    rcArea.right = rcArea.left + V_TB_MONITOR_LAYOUT_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + V_TB_MONITOR_LAYOUT_HEIGHT_NORMAL;
    break;

  case MonitorResolution_3M:
    rcArea.left = V_TB_MONITOR_LAYOUT_LEFT_3M;
    rcArea.top  = V_TB_MONITOR_LAYOUT_TOP_3M;
    rcArea.right = rcArea.left + V_TB_MONITOR_LAYOUT_WIDTH_3M;
    rcArea.bottom = rcArea.top + V_TB_MONITOR_LAYOUT_HEIGHT_3M;
    break;

  case MonitorResolution_5M:
    rcArea.left = V_TB_MONITOR_LAYOUT_LEFT_5M;
    rcArea.top  = V_TB_MONITOR_LAYOUT_TOP_5M;
    rcArea.right = rcArea.left + V_TB_MONITOR_LAYOUT_WIDTH_5M;
    rcArea.bottom = rcArea.top + V_TB_MONITOR_LAYOUT_HEIGHT_5M;
    break;

  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getMonitorLayoutPresetArea_h(MonitorResolutionType enumResType, 
                                                   CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = H_TB_MONITOR_LAYOUT_LEFT_NORMAL;
    rcArea.top  = H_TB_MONITOR_LAYOUT_TOP_NORMAL;
    rcArea.right = rcArea.left + H_TB_MONITOR_LAYOUT_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + H_TB_MONITOR_LAYOUT_HEIGHT_NORMAL;
    break;

  case MonitorResolution_3M:
    rcArea.left = H_TB_MONITOR_LAYOUT_LEFT_3M;
    rcArea.top  = H_TB_MONITOR_LAYOUT_TOP_3M;
    rcArea.right = rcArea.left + H_TB_MONITOR_LAYOUT_WIDTH_3M;
    rcArea.bottom = rcArea.top + H_TB_MONITOR_LAYOUT_HEIGHT_3M;
    break;

  case MonitorResolution_5M:
    rcArea.left = H_TB_MONITOR_LAYOUT_LEFT_5M;
    rcArea.top  = H_TB_MONITOR_LAYOUT_TOP_5M;
    rcArea.right = rcArea.left + H_TB_MONITOR_LAYOUT_WIDTH_5M;
    rcArea.bottom = rcArea.top + H_TB_MONITOR_LAYOUT_HEIGHT_5M;
    break;

  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getShowWorklistPresetArea(MonitorResolutionType enumResType, 
                                                ToolbarPosition enumToolbarPos, 
                                                CRect& rcArea)
{
  int nVertical = isVertical(enumToolbarPos);
  if(nVertical < 0)
    return ERROR_SUCCESS;

  if(nVertical == 1)
    return getShowWorklistPresetArea_v(enumResType, rcArea);
  else
    return getShowWorklistPresetArea_h(enumResType, rcArea);
}

DWORD CToolbarLayout::getShowWorklistPresetArea_v(MonitorResolutionType enumResType, 
                                                  CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = V_TB_SHOW_WORKLIST_BTN_LEFT_NORMAL;
    rcArea.top = V_TB_SHOW_WORKLIST_BTN_TOP_NORMAL;
    rcArea.right = rcArea.left + V_TB_SHOW_WORKLIST_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + V_TB_SHOW_WORKLIST_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = V_TB_SHOW_WORKLIST_BTN_LEFT_3M;
    rcArea.top = V_TB_SHOW_WORKLIST_BTN_TOP_3M;
    rcArea.right = rcArea.left + V_TB_SHOW_WORKLIST_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + V_TB_SHOW_WORKLIST_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = V_TB_SHOW_WORKLIST_BTN_LEFT_5M;
    rcArea.top = V_TB_SHOW_WORKLIST_BTN_TOP_5M;
    rcArea.right = rcArea.left + V_TB_SHOW_WORKLIST_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + V_TB_SHOW_WORKLIST_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getShowWorklistPresetArea_h(MonitorResolutionType enumResType, 
                                                  CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = H_TB_SHOW_WORKLIST_BTN_LEFT_NORMAL;
    rcArea.top = H_TB_SHOW_WORKLIST_BTN_TOP_NORMAL;
    rcArea.right = rcArea.left + H_TB_SHOW_WORKLIST_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + H_TB_SHOW_WORKLIST_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = H_TB_SHOW_WORKLIST_BTN_LEFT_3M;
    rcArea.top = H_TB_SHOW_WORKLIST_BTN_TOP_3M;
    rcArea.right = rcArea.left + H_TB_SHOW_WORKLIST_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + H_TB_SHOW_WORKLIST_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = H_TB_SHOW_WORKLIST_BTN_LEFT_5M;
    rcArea.top = H_TB_SHOW_WORKLIST_BTN_TOP_5M;
    rcArea.right = rcArea.left + H_TB_SHOW_WORKLIST_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + H_TB_SHOW_WORKLIST_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getPrevStudyPresetArea(MonitorResolutionType enumResType, 
                                             ToolbarPosition enumToolbarPos, 
                                             CRect& rcArea)
{
  int nVertical = isVertical(enumToolbarPos);
  if(nVertical < 0)
    return ERROR_SUCCESS;

  if(nVertical == 1)
    return getPrevStudyPresetArea_v(enumResType, rcArea);
  else
    return getPrevStudyPresetArea_h(enumResType, rcArea);
}

DWORD CToolbarLayout::getPrevStudyPresetArea_v(MonitorResolutionType enumResType, 
                                               CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = V_TB_PREV_STUDY_BTN_LEFT_NORMAL;
    rcArea.top = V_TB_PREV_STUDY_BTN_TOP_NORMAL;
    rcArea.right = rcArea.left + V_TB_PREV_STUDY_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + V_TB_PREV_STUDY_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = V_TB_PREV_STUDY_BTN_LEFT_3M;
    rcArea.top = V_TB_PREV_STUDY_BTN_TOP_3M;
    rcArea.right = rcArea.left + V_TB_PREV_STUDY_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + V_TB_PREV_STUDY_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = V_TB_PREV_STUDY_BTN_LEFT_5M;
    rcArea.top = V_TB_PREV_STUDY_BTN_TOP_5M;
    rcArea.right = rcArea.left + V_TB_PREV_STUDY_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + V_TB_PREV_STUDY_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getPrevStudyPresetArea_h(MonitorResolutionType enumResType, 
                                               CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = H_TB_PREV_STUDY_BTN_LEFT_NORMAL;
    rcArea.top = H_TB_PREV_STUDY_BTN_TOP_NORMAL;
    rcArea.right = rcArea.left + H_TB_PREV_STUDY_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + H_TB_PREV_STUDY_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = H_TB_PREV_STUDY_BTN_LEFT_3M;
    rcArea.top = H_TB_PREV_STUDY_BTN_TOP_3M;
    rcArea.right = rcArea.left + H_TB_PREV_STUDY_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + H_TB_PREV_STUDY_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = H_TB_PREV_STUDY_BTN_LEFT_5M;
    rcArea.top = H_TB_PREV_STUDY_BTN_TOP_5M;
    rcArea.right = rcArea.left + H_TB_PREV_STUDY_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + H_TB_PREV_STUDY_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getNextStudyPresetArea(MonitorResolutionType enumResType, 
                                             ToolbarPosition enumToolbarPos, 
                                             CRect& rcArea)
{
  int nVeritical = isVertical(enumToolbarPos);
  if(nVeritical < 0)
    return ERROR_INVALID_PARAMETER;

  if(nVeritical == 1)
    return getNextStudyPresetArea_v(enumResType, rcArea);
  else
    return getNextStudyPresetArea_h(enumResType, rcArea);
}

DWORD CToolbarLayout::getNextStudyPresetArea_v(MonitorResolutionType enumResType, 
                                               CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = V_TB_NEXT_STUDY_BTN_LEFT_NORMAL;
    rcArea.top  = V_TB_NEXT_STUDY_BTN_TOP_NORMAL;
    rcArea.right = rcArea.left + V_TB_NEXT_STUDY_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + V_TB_NEXT_STUDY_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = V_TB_NEXT_STUDY_BTN_LEFT_3M;
    rcArea.top  = V_TB_NEXT_STUDY_BTN_TOP_3M;
    rcArea.right = rcArea.left + V_TB_NEXT_STUDY_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + V_TB_NEXT_STUDY_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = V_TB_NEXT_STUDY_BTN_LEFT_5M;
    rcArea.top  = V_TB_NEXT_STUDY_BTN_TOP_5M;
    rcArea.right = rcArea.left + V_TB_NEXT_STUDY_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + V_TB_NEXT_STUDY_BTN_HEIGHT_5M;
    break;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getNextStudyPresetArea_h(MonitorResolutionType enumResType, 
                                               CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = H_TB_NEXT_STUDY_BTN_LEFT_NORMAL;
    rcArea.top  = H_TB_NEXT_STUDY_BTN_TOP_NORMAL;
    rcArea.right = rcArea.left + H_TB_NEXT_STUDY_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + H_TB_NEXT_STUDY_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = H_TB_NEXT_STUDY_BTN_LEFT_3M;
    rcArea.top  = H_TB_NEXT_STUDY_BTN_TOP_3M;
    rcArea.right = rcArea.left + H_TB_NEXT_STUDY_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + H_TB_NEXT_STUDY_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = H_TB_NEXT_STUDY_BTN_LEFT_5M;
    rcArea.top  = H_TB_NEXT_STUDY_BTN_TOP_5M;
    rcArea.right = rcArea.left + H_TB_NEXT_STUDY_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + H_TB_NEXT_STUDY_BTN_HEIGHT_5M;
    break;
  }

  return ERROR_SUCCESS;
}

DWORD 
  CToolbarLayout::getStudyViewLayoutPresetArea(MonitorResolutionType enumResType, 
                                               ToolbarPosition enumToolbarPos, 
                                               CRect& rcArea)
{
  int nVertical = isVertical(enumToolbarPos);
  if(nVertical < 0)
    return ERROR_INVALID_PARAMETER;

  if(nVertical)
    return getStudyViewLayoutPresetArea_v(enumResType, rcArea);
  else
    return getStudyViewLayoutPresetArea_h(enumResType, rcArea);
}

DWORD CToolbarLayout::getStudyViewLayoutPresetArea_v(MonitorResolutionType enumResType, 
                                                     CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = V_TB_STUDY_VIEW_LAYOUT_LEFT_NORMAL;
    rcArea.top = V_TB_STUDY_VIEW_LAYOUT_TOP_NORMAL;
    rcArea.right = rcArea.left + V_TB_STUDY_VIEW_LAYOUT_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + V_TB_STUDY_VIEW_LAYOUT_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = V_TB_STUDY_VIEW_LAYOUT_LEFT_3M;
    rcArea.top = V_TB_STUDY_VIEW_LAYOUT_TOP_3M;
    rcArea.right = rcArea.left + V_TB_STUDY_VIEW_LAYOUT_WIDTH_3M;
    rcArea.bottom = rcArea.top + V_TB_STUDY_VIEW_LAYOUT_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = V_TB_STUDY_VIEW_LAYOUT_LEFT_5M;
    rcArea.top = V_TB_STUDY_VIEW_LAYOUT_TOP_5M;
    rcArea.right = rcArea.left + V_TB_STUDY_VIEW_LAYOUT_WIDTH_5M;
    rcArea.bottom = rcArea.top + V_TB_STUDY_VIEW_LAYOUT_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getStudyViewLayoutPresetArea_h(MonitorResolutionType enumResType, 
                                                     CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = H_TB_STUDY_VIEW_LAYOUT_LEFT_NORMAL;
    rcArea.top = H_TB_STUDY_VIEW_LAYOUT_TOP_NORMAL;
    rcArea.right = rcArea.left + H_TB_STUDY_VIEW_LAYOUT_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + H_TB_STUDY_VIEW_LAYOUT_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = H_TB_STUDY_VIEW_LAYOUT_LEFT_3M;
    rcArea.top = H_TB_STUDY_VIEW_LAYOUT_TOP_3M;
    rcArea.right = rcArea.left + H_TB_STUDY_VIEW_LAYOUT_WIDTH_3M;
    rcArea.bottom = rcArea.top + H_TB_STUDY_VIEW_LAYOUT_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = H_TB_STUDY_VIEW_LAYOUT_LEFT_5M;
    rcArea.top = H_TB_STUDY_VIEW_LAYOUT_TOP_5M;
    rcArea.right = rcArea.left + H_TB_STUDY_VIEW_LAYOUT_WIDTH_5M;
    rcArea.bottom = rcArea.top + H_TB_STUDY_VIEW_LAYOUT_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getHideToolbarPresetArea(MonitorResolutionType enumResType, 
                                               ToolbarPosition enumToolbarPos, 
                                               CRect& rcArea)
{
  int nVertical = isVertical(enumToolbarPos);
  if(nVertical < 0)
    return ERROR_INVALID_PARAMETER;

  if(nVertical)
    return getHideToolbarPresetArea_v(enumResType, rcArea);
  else
    return getHideToolbarPresetArea_h(enumResType, rcArea);
}

DWORD CToolbarLayout::getHideToolbarPresetArea_v(MonitorResolutionType enumResType, 
                                                 CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = V_TB_HIDE_TOOLBAR_LEFT_NORMAL;
    rcArea.top  = V_TB_HIDE_TOOLBAR_TOP_NORMAL;
    rcArea.right = rcArea.left + V_TB_HIDE_TOOLBAR_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + V_TB_HIDE_TOOLBAR_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = V_TB_HIDE_TOOLBAR_LEFT_3M;
    rcArea.top  = V_TB_HIDE_TOOLBAR_TOP_3M;
    rcArea.right = rcArea.left + V_TB_HIDE_TOOLBAR_WIDTH_3M;
    rcArea.bottom = rcArea.top + V_TB_HIDE_TOOLBAR_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = V_TB_HIDE_TOOLBAR_LEFT_5M;
    rcArea.top  = V_TB_HIDE_TOOLBAR_TOP_5M;
    rcArea.right = rcArea.left + V_TB_HIDE_TOOLBAR_WIDTH_5M;
    rcArea.bottom = rcArea.top + V_TB_HIDE_TOOLBAR_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getHideToolbarPresetArea_h(MonitorResolutionType enumResType, 
                                                 CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = H_TB_HIDE_TOOLBAR_LEFT_NORMAL;
    rcArea.top  = H_TB_HIDE_TOOLBAR_TOP_NORMAL;
    rcArea.right = rcArea.left + H_TB_HIDE_TOOLBAR_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + H_TB_HIDE_TOOLBAR_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = H_TB_HIDE_TOOLBAR_LEFT_3M;
    rcArea.top  = H_TB_HIDE_TOOLBAR_TOP_3M;
    rcArea.right = rcArea.left + H_TB_HIDE_TOOLBAR_WIDTH_3M;
    rcArea.bottom = rcArea.top + H_TB_HIDE_TOOLBAR_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = H_TB_HIDE_TOOLBAR_LEFT_5M;
    rcArea.top  = H_TB_HIDE_TOOLBAR_TOP_5M;
    rcArea.right = rcArea.left + H_TB_HIDE_TOOLBAR_WIDTH_5M;
    rcArea.bottom = rcArea.top + H_TB_HIDE_TOOLBAR_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getShowToolboxPresetStackArea(MonitorResolutionType enumResType, 
                                                    ToolbarPosition enumToolbarPos, 
                                                    CRect& rcArea)
{
  int nVeritical = isVertical(enumToolbarPos);
  if(nVeritical < 0)
    return ERROR_INVALID_PARAMETER;

  if(nVeritical)
    return getShowToolboxStackPresetArea_v(enumResType, rcArea);
  else
    return getShowToolboxStackPresetArea_h(enumResType, rcArea);
}

DWORD CToolbarLayout::getShowToolboxStackPresetArea_v(MonitorResolutionType enumResType, 
                                                      CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = V_TB_SHOW_TOOLBOX_STACK_BTN_LEFT_NORMAL;
    rcArea.top  = V_TB_SHOW_TOOLBOX_STACK_BTN_TOP_NORMAL;
    rcArea.right = rcArea.left + V_TB_SHOW_TOOLBOX_STACK_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + V_TB_SHOW_TOOLBOX_STACK_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = V_TB_SHOW_TOOLBOX_STACK_BTN_LEFT_3M;
    rcArea.top  = V_TB_SHOW_TOOLBOX_STACK_BTN_TOP_3M;
    rcArea.right = rcArea.left + V_TB_SHOW_TOOLBOX_STACK_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + V_TB_SHOW_TOOLBOX_STACK_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = V_TB_SHOW_TOOLBOX_STACK_BTN_LEFT_5M;
    rcArea.top  = V_TB_SHOW_TOOLBOX_STACK_BTN_TOP_5M;
    rcArea.right = rcArea.left + V_TB_SHOW_TOOLBOX_STACK_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + V_TB_SHOW_TOOLBOX_STACK_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getShowToolboxStackPresetArea_h(MonitorResolutionType enumResType, 
                                                      CRect& rcArea)
{
  switch(enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = H_TB_SHOW_TOOLBOX_STACK_BTN_LEFT_NORMAL;
    rcArea.top  = H_TB_SHOW_TOOLBOX_STACK_BTN_TOP_NORMAL;
    rcArea.right = rcArea.left + H_TB_SHOW_TOOLBOX_STACK_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + H_TB_SHOW_TOOLBOX_STACK_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = H_TB_SHOW_TOOLBOX_STACK_BTN_LEFT_3M;
    rcArea.top  = H_TB_SHOW_TOOLBOX_STACK_BTN_TOP_3M;
    rcArea.right = rcArea.left + H_TB_SHOW_TOOLBOX_STACK_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + H_TB_SHOW_TOOLBOX_STACK_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = H_TB_SHOW_TOOLBOX_STACK_BTN_LEFT_5M;
    rcArea.top  = H_TB_SHOW_TOOLBOX_STACK_BTN_TOP_5M;
    rcArea.right = rcArea.left + H_TB_SHOW_TOOLBOX_STACK_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + H_TB_SHOW_TOOLBOX_STACK_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
  }

  return ERROR_SUCCESS;
}

DWORD 
  CToolbarLayout::getShowThumbPresetArea(MonitorResolutionType enumResType, 
                                         ToolbarPosition enumToolbarPos, 
                                         CRect& rcArea)
{
  int nVertical = isVertical(enumToolbarPos);
  if(nVertical < 0)
    return ERROR_INVALID_PARAMETER;

  if(nVertical)
    return getShowThumbPresetArea_v(enumResType, rcArea);
  else
    return getShowThumbPresetArea_h(enumResType, rcArea);
}

DWORD CToolbarLayout::getShowThumbPresetArea_v(MonitorResolutionType enumResType, 
                                               CRect& rcArea)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = V_TB_SHOW_THUMB_BTN_LEFT_NORMAL;
    rcArea.top  = V_TB_SHOW_THUMB_BTN_TOP_NORMAL;
    rcArea.right = rcArea.left + V_TB_SHOW_THUMB_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + V_TB_SHOW_THUMB_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = V_TB_SHOW_THUMB_BTN_LEFT_3M;
    rcArea.top  = V_TB_SHOW_THUMB_BTN_TOP_3M;
    rcArea.right = rcArea.left + V_TB_SHOW_THUMB_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + V_TB_SHOW_THUMB_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = V_TB_SHOW_THUMB_BTN_LEFT_5M;
    rcArea.top  = V_TB_SHOW_THUMB_BTN_TOP_5M;
    rcArea.right = rcArea.left + V_TB_SHOW_THUMB_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + V_TB_SHOW_THUMB_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }
  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getShowThumbPresetArea_h(MonitorResolutionType enumResType, 
                                               CRect& rcArea)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = H_TB_SHOW_THUMB_BTN_LEFT_NORMAL;
    rcArea.top  = H_TB_SHOW_THUMB_BTN_TOP_NORMAL;
    rcArea.right = rcArea.left + H_TB_SHOW_THUMB_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + H_TB_SHOW_THUMB_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = H_TB_SHOW_THUMB_BTN_LEFT_3M;
    rcArea.top  = H_TB_SHOW_THUMB_BTN_TOP_3M;
    rcArea.right = rcArea.left + H_TB_SHOW_THUMB_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + H_TB_SHOW_THUMB_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = H_TB_SHOW_THUMB_BTN_LEFT_5M;
    rcArea.top  = H_TB_SHOW_THUMB_BTN_TOP_5M;
    rcArea.right = rcArea.left + H_TB_SHOW_THUMB_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + H_TB_SHOW_THUMB_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }
  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getMinimizePresetArea(MonitorResolutionType enumResType, 
                                            ToolbarPosition enumToolbarPos, 
                                            const CRect& rcParent,
                                            CRect& rcArea)
{
  int nVertical = isVertical(enumToolbarPos);
  if(nVertical < 0)
    return ERROR_INVALID_PARAMETER;

  if(nVertical)
    return getMinimizePresetArea_v(enumResType, rcParent, rcArea);
  else
    return getMinimizePresetArea_h(enumResType, rcParent, rcArea);
}

DWORD CToolbarLayout::getMinimizePresetArea_v(MonitorResolutionType enumResType, 
                                              const CRect& rcParent, 
                                              CRect& rcArea)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = V_TB_MINI_BTN_LEFT_NORMAL;
    rcArea.top = rcParent.bottom - V_TB_MINI_BTN_HEIGHT_NORMAL - V_TB_BTN_TOP_MARGIN_NORMAL;
    rcArea.right = rcArea.left + V_TB_MINI_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top +  V_TB_MINI_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = V_TB_MINI_BTN_LEFT_3M;
    rcArea.top = rcParent.bottom - V_TB_MINI_BTN_HEIGHT_3M - V_TB_BTN_TOP_MARGIN_3M;
    rcArea.right = rcArea.left + V_TB_MINI_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top +  V_TB_MINI_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = V_TB_MINI_BTN_LEFT_5M;
    rcArea.top = rcParent.bottom - V_TB_MINI_BTN_HEIGHT_5M - V_TB_BTN_TOP_MARGIN_5M;
    rcArea.right = rcArea.left + V_TB_MINI_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top +  V_TB_MINI_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }
  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getMinimizePresetArea_h(MonitorResolutionType enumResType, 
                                              const CRect& rcParent, 
                                              CRect& rcArea)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.top = H_TB_MINI_BTN_TOP_NORMAL;
    rcArea.right = rcParent.right - H_TB_BTN_LEFT_MARGIN_NORMAL;
    rcArea.left = rcArea.right - H_TB_MINI_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + H_TB_MINI_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.top = H_TB_MINI_BTN_TOP_3M;
    rcArea.right = rcParent.right - H_TB_BTN_LEFT_MARGIN_3M;
    rcArea.left = rcArea.right - H_TB_MINI_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + H_TB_MINI_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.top = H_TB_MINI_BTN_TOP_5M;
    rcArea.right = rcParent.right - H_TB_BTN_LEFT_MARGIN_5M;
    rcArea.left = rcArea.right - H_TB_MINI_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + H_TB_MINI_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }
  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getExitPresetArea(MonitorResolutionType enumResType, 
                                        ToolbarPosition enumToolbarPos, 
                                        const CRect& rcParent, 
                                        CRect& rcArea)
{
  int nVertical = isVertical(enumToolbarPos);
  if(nVertical < 0)
    return ERROR_INVALID_PARAMETER;

  if(nVertical)
    return getExitPresetArea_v(enumResType, rcParent, rcArea);
  else
    return getExitPresetArea_h(enumResType, rcParent, rcArea);
}

DWORD CToolbarLayout::getExitPresetArea_v(MonitorResolutionType enumResType, 
                                          const CRect& rcParent, 
                                          CRect& rcArea)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.left = V_TB_EXIT_BTN_LEFT_NORMAL;
    rcArea.top  = rcParent.bottom - V_TB_EXIT_BTN_HEIGHT_NORMAL - V_TB_BTN_TOP_MARGIN_NORMAL;
    rcArea.right = rcArea.left + V_TB_EXIT_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + V_TB_EXIT_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.left = V_TB_EXIT_BTN_LEFT_3M;
    rcArea.top  = rcParent.bottom - V_TB_EXIT_BTN_HEIGHT_3M - V_TB_BTN_TOP_MARGIN_3M;
    rcArea.right = rcArea.left + V_TB_EXIT_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + V_TB_EXIT_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.left = V_TB_EXIT_BTN_LEFT_5M;
    rcArea.top  = rcParent.bottom - V_TB_EXIT_BTN_HEIGHT_5M - V_TB_BTN_TOP_MARGIN_5M;
    rcArea.right = rcArea.left + V_TB_EXIT_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + V_TB_EXIT_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getExitPresetArea_h(MonitorResolutionType enumResType, 
                                          const CRect& rcParent, 
                                          CRect& rcArea)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    rcArea.top = H_TB_EXIT_BTN_TOP_NORMAL;
    rcArea.right = rcParent.right - H_TB_BTN_LEFT_MARGIN_NORMAL;
    rcArea.left = rcArea.right - H_TB_EXIT_BTN_WIDTH_NORMAL;
    rcArea.bottom = rcArea.top + H_TB_MINI_BTN_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    rcArea.top = H_TB_EXIT_BTN_TOP_3M;
    rcArea.right = rcParent.right - H_TB_BTN_LEFT_MARGIN_3M;
    rcArea.left = rcArea.right - H_TB_EXIT_BTN_WIDTH_3M;
    rcArea.bottom = rcArea.top + H_TB_MINI_BTN_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    rcArea.top = H_TB_EXIT_BTN_TOP_5M;
    rcArea.right = rcParent.right - H_TB_BTN_LEFT_MARGIN_5M;
    rcArea.left = rcArea.right - H_TB_EXIT_BTN_WIDTH_5M;
    rcArea.bottom = rcArea.top + H_TB_MINI_BTN_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getToolboxStackPresetLeftTop(MonitorResolutionType enumResType, 
                                                   ToolbarPosition enumToolbarPos, 
                                                   CPoint& ptLeftTop)
{
  int nVertical = isVertical(enumToolbarPos);
  if(nVertical < 0)
    return ERROR_INVALID_PARAMETER;

  if(nVertical)
    return getToolboxStackPresetLeftTop_v(enumResType,
    ptLeftTop);
  else
    return getToolboxStackPresetLeftTop_h(enumResType,
    ptLeftTop);
}

DWORD CToolbarLayout::getToolboxStackPresetLeftTop_v(MonitorResolutionType enumResType, 
                                                     CPoint& ptLeftTop)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    ptLeftTop.x = V_TB_TOOLBOX_LEFT_NORMAL;
    ptLeftTop.y = V_TB_TOOLBOX_TOP_NORMAL;
    break;
  case MonitorResolution_3M:
    ptLeftTop.x = V_TB_TOOLBOX_LEFT_3M;
    ptLeftTop.y = V_TB_TOOLBOX_TOP_3M;
    break;
  case MonitorResolution_5M:
    ptLeftTop.x = V_TB_TOOLBOX_LEFT_5M;
    ptLeftTop.y = V_TB_TOOLBOX_TOP_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }

  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getToolboxStackPresetLeftTop_h(MonitorResolutionType enumResType, 
                                                     CPoint& ptLeftTop)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    ptLeftTop.x = H_TB_TOOLBOX_LEFT_NORMAL;
    ptLeftTop.y = H_TB_TOOLBOX_TOP_NORMAL;
    break;
  case MonitorResolution_3M:
    ptLeftTop.x = H_TB_TOOLBOX_LEFT_3M;
    ptLeftTop.y = H_TB_TOOLBOX_TOP_3M;
    break;
  case MonitorResolution_5M:
    ptLeftTop.x = H_TB_TOOLBOX_LEFT_5M;
    ptLeftTop.y = H_TB_TOOLBOX_TOP_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }
  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getToolboxStackPresetWidth(MonitorResolutionType enumResType, 
                                                 int& nWidth)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    nWidth = V_TB_TOOLBOX_WIDTH_NORMAL;
    break;
  case MonitorResolution_3M:
    nWidth = V_TB_TOOLBOX_WIDTH_3M;
    break;
  case MonitorResolution_5M:
    nWidth = V_TB_TOOLBOX_WIDTH_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }
  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getToolboxStackPresetHeight(MonitorResolutionType enumResType, 
                                                  int& nHeight)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    nHeight = H_TB_TOOLBOX_HEIGHT_NORMAL;
    break;
  case MonitorResolution_3M:
    nHeight = H_TB_TOOLBOX_HEIGHT_3M;
    break;
  case MonitorResolution_5M:
    nHeight = H_TB_TOOLBOX_HEIGHT_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }
  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getToolbarButtonMargin(MonitorResolutionType enumResType, 
                                             ToolbarPosition enumToolbarPos, 
                                             CSize& csMargin)
{
  int nVertical = isVertical(enumToolbarPos);
  if(nVertical < 0) 
    return ERROR_INVALID_PARAMETER;

  if(nVertical)
    return getToolbarButtonMargin_v(enumResType, csMargin);
  else
    return getToolbarButtonMargin_h(enumResType, csMargin);
}

DWORD CToolbarLayout::getToolbarButtonMargin_v(MonitorResolutionType enumResType, 
                                               CSize& csMargin)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    csMargin.cx = V_TB_BTN_LEFT_MARGIN_NORMAL;
    csMargin.cy = V_TB_BTN_TOP_MARGIN_NORMAL;
    break;
  case MonitorResolution_3M:
    csMargin.cx = V_TB_BTN_LEFT_MARGIN_3M;
    csMargin.cy = V_TB_BTN_TOP_MARGIN_3M;
    break;
  case MonitorResolution_5M:
    csMargin.cx = V_TB_BTN_LEFT_MARGIN_5M;
    csMargin.cy = V_TB_BTN_TOP_MARGIN_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }
  return ERROR_SUCCESS;
}

DWORD CToolbarLayout::getToolbarButtonMargin_h(MonitorResolutionType enumResType, 
                                               CSize& csMargin)
{
  switch (enumResType)
  {
  case MonitorResolution_Normal:
    csMargin.cx = H_TB_BTN_LEFT_MARGIN_NORMAL;
    csMargin.cy = H_TB_BTN_TOP_MARGIN_NORMAL;
    break;
  case MonitorResolution_3M:
    csMargin.cx = H_TB_BTN_LEFT_MARGIN_3M;
    csMargin.cy = H_TB_BTN_TOP_MARGIN_3M;
    break;
  case MonitorResolution_5M:
    csMargin.cx = H_TB_BTN_LEFT_MARGIN_5M;
    csMargin.cy = H_TB_BTN_TOP_MARGIN_5M;
    break;
  default:
    return ERROR_INVALID_PARAMETER;
    break;
  }
  return ERROR_SUCCESS;
}

int CToolbarLayout::getHiddenToobarSize(MonitorResolutionType resType)
{
  int size = 0;
  switch (resType)
  {
  case MonitorResolution_Normal:
    size = HIDDEN_TB_SIZE_NORMAL;
    break;
  case MonitorResolution_3M:
    size = HIDDEN_TB_SIZE_3M;
    break;
  case MonitorResolution_5M:
    size = HIDDEN_TB_SIZE_5M;
    break;
  default:
    break;
  }

  return size;
}

int CToolbarLayout::isVertical(IN ToolbarPosition enumPos)
{
  switch(enumPos)
  {
  case ToolbarPositionLeft:
  case ToolbarPositionRight:
    return 1;
  case ToolbarPositionTop:
  case ToolbarPositionBottom:
    return 0;
  default:
    return -1;
  }
}